home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-14 | 8.1 KB | 422 lines | [TEXT/sLiN] |
- ! Version 3.0
- !
- !$ Use this script with Rockwell-based (Supra, Xeba, Zoom, Hayes Optima, etc)
- !$ data/fax modems.
- !$ Supports: fax, ARA and regular data incoming calls.
- !
- !$ Make sure that *Class 1* fax software is installed
- !
- !$ A cable for hardware handshaking is required
-
- ^2 Speaker On: = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
- ^3 Speaker Volume: = Enum("Low"="1","Medium"="2","High"="3") "2"
- ^4 Answer On: = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
- ^5 Port Speed: = Enum("9600","19200","38400","57600") "19200"
- ^6 Handshake wires: = Bool("Both"="&D0","CTS only"="&D2") "&D2"
- ^7 Fax Port Speed: = Bool("Fixed"="F","Auto"="V") "V"
- ! ------------------------------------------
- ! Resetting the modem:
- ! ------------------------------------------
- @Hangup
- SetTries 2
- Flush
- HsReset 0,0,17,19,0,0
- DtrSet
- !
- ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
- ! to enter the command mode
- !
- @Label 1
- matchclr
- matchstr 1 2 "OK\r\n"
- write "ATH0&F\r"
- matchread 20
- ChrDelay 1
- Write "+++"
- ChrDelay 0
- DtrClear
- SBreak
- DtrSet
- !
- DecTries
- IfTries 0 1
- !
- ! OSErr -6019 "Modem error - the modem is not responding"
- !
- exit -6019
- @Label 2
- write "AT+FCLASS=0\r"
- Jsr 100
- write "AT+FAE=0\r"
- Jsr 100
- exit 0
-
- ! ------------------------------------------
- ! Receiving incoming calls
- ! ------------------------------------------
- @ANSWER
- !
- ! Set the modem preferred speed first
- !
- SerReset Val("^5"),0,8,1
- Jsr 80
-
- @Label 10
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- ! • &Q6: Normal connection (for ARA)
- ! • &K3: HW flow control (for ARA, Fax should not use a handshake on receiving)
- ! • W1: report connection speed
- !
- Write "AT&Q6&K3W1\r"
- Jsr 100
- !
- ! Set Fax mode
- !
- Write "AT+FCLASS=1\r"
- Jsr 100
- Write "AT+FAE=1\r"
- Jsr 100
- !
- ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
- ! it cannot accept data calls
- !
- Write "AT+FCLASS=0\r"
- Jsr 100
- !
- ! Tell the modem to determine the type of the incoming call
- ! Fetch the tube after ^4 rings
- !
- Write "ATS0=^4V0\r"
- Jsr 110
- !
- ! Everything is ready - let's sit and wait for a call
- ! We'll wait for 2 minutes, then reinitiate the modem
- !
- Note "Waiting for a fax/ARA/data call…"
- MatchClr
- matchstr 02 40 "47\r"
- MatchStr 03 41 "48\r"
- MatchStr 04 42 "49\r"
- MatchStr 05 43 "50\r"
- MatchStr 06 44 "51\r"
- MatchStr 07 45 "52\r"
- MatchStr 08 46 "53\r"
- MatchStr 09 47 "54\r"
- MatchStr 10 48 "55\r"
- MatchStr 11 49 "56\r"
- MatchStr 12 50 "57\r"
- MatchStr 13 51 "55\r"
-
- MatchStr 15 19 "33\r"
- matchstr 16 18 "2\r"
- matchstr 17 57 "1\r"
- matchstr 18 17 "3\r"
- matchstr 19 17 "8\r"
- matchstr 20 17 "7\r"
- @Label 16
- Matchread 1200
- @Label 17
- Note "Tuning again…"
- Write "ATV1\r"
- Jsr 100
- Jump 10
- @Label 18
- Note "Ring…"
- jump 16
- @Label 19
- Note "Fax tones detected…"
- IfStr 7 16 "V"
- SetSpeed 19200
- Jump 16
-
- !
- ! Data connection has been established (we read "CONNECT")
- ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
- ! if it was an incoming call, put the "RING" before the "CONNECT"
- !
- @Label 20
- IfOpen "Data" 21
- Jump 30
- @Label 21
- IfOpen "ARA" 22
- Jump 35
- @Label 22
- Note "Waiting for an ARA frame"
- MatchClr
- MatchStr 1 23 "^$\r"
- MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
- MatchStr 3 29 "\01\27\02\29\01\02\01\06"
- MatchRead 60
- Jump 24
- @Label 23
- QueueInput "^$\r"
- @Label 24
- Note "Non-ARA call"
- Jump 35
-
- @Label 28
- Note "ARA 1.0 call"
- Jump 30
- @Label 29
- Note "ARA 2.0 call"
- Jump 30
-
- @Label 30
- QueueInput "\r\nCARRIER ^B\r\n"
- QueueInput "\r\nRING\r\n"
- Attach "ARA" (DTR)
-
- @Label 35
- GetSReg C "DATA" 4
- QueueInput "\r^CCONNECT ^B\r^C"
- ifOriginate 36
- QueueInput "\r^CRING\r^C"
- @Label 36
- Attach "Data" (DTR,Escape,Break)
-
-
- !
- ! Converting numeric responses into the verbal
- !
- @Label 40
- SetVar B "2400"
- Jump 20
- @Label 41
- SetVar B "4800"
- Jump 20
- @Label 42
- SetVar B "7200"
- Jump 20
- @Label 43
- SetVar B "9600"
- Jump 20
- @Label 44
- SetVar B "12000"
- Jump 20
- @Label 45
- SetVar B "14400"
- Jump 20
- @Label 46
- SetVar B "16800"
- Jump 20
- @Label 47
- SetVar B "19200"
- Jump 20
- @Label 48
- SetVar B "21600"
- Jump 20
- @Label 49
- SetVar B "24000"
- Jump 20
- @Label 50
- SetVar B "26400"
- Jump 20
- @Label 51
- SetVar B "28800"
- Jump 20
-
- ! ------------------------------------------
- ! Originating a call through the "ARA" subport
- ! ------------------------------------------
- @ORIGINATE "ARA"
- SerReset Val("^5"),0,8,1
- Jsr 80
- !
- ! Set the common options
- !
- Jsr 70
- !
- ! Set the Data mode:
- ! • &Q6:Normal connection (no compression, correction - for ARA)
- ! • &K3: HW Handshake
- ! • S7: time-out (90 sec) for long-distance call (if you use them)
- ! • W1: report connection rate
- !
- Write "AT&Q6&K3S7=90W1\r"
- Jsr 100
- !
- ! Emit the ARA script commands ("Xnn")
- Jsr 60
- !
- ! Prepare to receive all error result codes, dial the number
- !
- Jsr 90
- MatchStr 1 55 "\r\nCARRIER "
- MatchRead 1000
- Write "\r"
- Exit -6019
- @Label 55
- QueueInput "\r\nCARRIER "
- Attach "ARA" (DTR)
-
- ! ------------------------------------------
- ! Originating a call through the "DATA" subport
- ! ------------------------------------------
- @ORIGINATE "Data"
- SerReset Val("^5"),0,8,1
- Jsr 80
- !
- ! Set the common options
- !
- Jsr 70
- !
- ! Set the Data mode:
- ! • \N3: Auto-reliable
- ! • &K3: HW Handshake
- ! • S7: time-out (90 sec) for long-distance call (if you use them)
- !
- Write "AT&K3S7=90\r"
- Jsr 100
- !
- ! Emit the Data commands
- Jsr 60
- !
- ! Prepare to receive all error result codes, dial the number
- !
- Jsr 90
- MatchStr 1 56 "\r\nCONNECT "
- MatchRead 1000
- Write "\r"
- Exit -6019
- @Label 56
- QueueInput "\r\nCONNECT "
- Attach "Data" (DTR,Escape,Break)
-
- ! ------------------------------------------
- ! Originating a call through the "Fax" subPort
- ! ------------------------------------------
- @ORIGINATE "Fax"
- !
- ! Set the "Fax" speed
- !
- SerReset 19200,0,8,1
- Jsr 80
- !
- ! Set the common options
- !
- Jsr 70
- !
- ! Set the Fax mode
- ! &K4: Xon/Xoff handshake
- ! &S0: DSR always on (see above)
- !
- Write "AT&S0&K4+FCLASS=1\r"
- Jsr 100
- !
- ! Now emit all commands that the application has sent to that port,
- ! except "FCLASS", etc
- !
- EmitClear "+FCLASS","V","E"
- Jsr 60
- Write "ATV0\r"
- Jsr 110
- !
- ! Prepare to receive all error result codes, dial the number
- !
- MatchClr
- MatchStr 01 57 "1\r"
- MatchStr 13 93 "3\r"
- MatchStr 14 94 "8\r"
- MatchStr 15 92 "7\r"
- Write "ATD^1\r"
- HsReset *
- MatchRead 900
- Write "\r"
- Exit -6019
-
- !
- ! Fax connection has been established (we read "FAX")
- ! Put the +FCON back to the buffer,
- ! if it was an incoming call, put the "RING" before the "+FCON"
- ! Attach the "Fax" subPort
- !
- @Label 57
- QueueInput "1\r"
- IfStr 7 58 "V"
- SetSpeed 19200
- @Label 58
- ifOriginate 59
- QueueInput "2\r2\r"
- @Label 59
- Attach "Fax" (Reset(2400),IdleLimit=30)
-
- !
- ! This section emits all modem commands sent from the client application
- ! For each set of commands the "OK" answer is awaited
- !
- @Label 60
- EmitStart
- @Label 61
- EmitCommand 62
- Jsr 100
- Jump 61
- @Label 62
- return
- !
- ! This section initiates the modem before ANSWER and ORIGINATEs:
- ! extended responses + connect at the highest rate + speaker control +
- ! reset on Dtr drop + DCD valid
- ! Verbal responses mode, no echo
- !
- @Label 70
- Write "ATX4N1M^2L^3^6&C1V1E0\r"
- Jsr 100
- return
-
- !
- ! This section syncronize the modem after the serial port speed switching
- !
- @Label 80
- ChrDelay 1
- Write "AT\r"
- ChrDelay 0
- Jsr 100
- return
- !
- ! Prepare to receive error result codes, send the dialing command and
- ! set the user's handshake mode
- !
- @Label 90
- MatchClr
- MatchStr 2 91 "NO DIALTONE\r\n"
- MatchStr 3 92 "BUSY\r\n"
- MatchStr 4 93 "NO CARRIER\r\n"
- MatchStr 5 94 "NO ANSWER\r\n"
- Write "ATD^1\r"
- HsReset *
- return
- @Label 91
- exit -6020
- @Label 92
- exit -6022
- @Label 93
- exit -6021
- @Label 94
- exit -6023
- !
- ! Processing the AT command:
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 100
- MatchClr
- MatchStr 1 103 "\r\nOK\r\n"
- MatchStr 2 102 "\r\nERROR\r\n"
- @Label 101
- MatchRead 20
- @Label 102
- Exit -6019
- @Label 103
- return
-
- @Label 110
- MatchClr
- MatchStr 1 103 "0\r"
- MatchStr 2 102 "4\r"
- Jump 101
-